#include <QPainter>
#include "LampWidget.h"

LampWidget::LampWidget(QWidget *parent) :
	QWidget(parent)
{
	m_strPath[0] = "://resource/image/05_lamp_normal.png";
	m_strPath[1] =	"://resource/image/05_lamp_green_select.png";
	m_strPath[2] = "://resource/image/05_lamp_orange_select.png";
	m_strPath[3] = "://resource/image/05_lamp_red_select.png";
	m_strPath[4] = "://resource/image/05_lamp_blue_select.png";
	this->changeState(eStGray);
}

void LampWidget::changeState(EColor color)
{
	m_pixmap.load(m_strPath[color]);
	this->update();
}

void LampWidget::paintEvent(QPaintEvent *event)
{
	QPainter painter(this);
	QSize size(m_pixmap.size());
	QRect rect(this->rect());

	size.scale(this->size(), Qt::KeepAspectRatio);
	rect.setSize(size);
	rect.moveCenter(this->rect().center());
	painter.drawPixmap(rect, m_pixmap);
}
